import {
    useEffect,
    useState
} from 'react';
import { View } from '@tarojs/components';
import Taro from "@tarojs/taro";

import { SingleButtonFooter } from '@/pages/components/footerOperation/singleButtonFooter'
import LgEmpty from '@/pages/components/emptyContent'
import LgCheckbox from '@/pages/components/checkbox'
import Header from '@/pages/components/navCustomBar'
import Utils from '@/utils/index'
import { connect, useDispatch } from 'react-redux';
import { setSelectUser } from '@/store/slice'
import { HttpGet } from '@/network/servers'
import "./index.scss";

var lodash = require('lodash')
const {
    getNowToken
} = Utils

function App(props) {

    let {
        userInfo,
        leaveAddr,
        oaAddr,
        baseAddr,
        env,
        schoolInfo,
        selectUserList1,
        lg_ic,
        baseUrl
    } = props

    if (!lg_ic) {
        lg_ic = Utils.getQueryVariable('lg_ic')
    }
    const dispatch = useDispatch()

    const [historyList, setHistoryList] = useState([{ name: "全部" }]);
    const [selectDataList, setSelectDataList] = useState([]);
    const [webAddr, setWebAddr] = useState("");
    const [selectUserList, setSelectUserList] = useState([])
    const [routerParams, setRouterParams] = useState({});
    const [reflash, setReflash] = useState(false);
    //递归遍历对象，返回被选中的对象
    const getHasChob = (arr, data) => {
        // console.log(arr, data)
        data.forEach((item) => {
            if (item.children) {
                getHasChob(arr, item.children);
            } else {
                if (item.hasCho) {
                    arr.push(item);
                }
            }
        })
        return arr;
    }
    const getGroupData = async (data) => {
        // console.log('data2', data)

        // let lg_ic = 'IC0010'
        let lg_ic = userInfo.identityCode
        // let userType = 0
        let userType = userInfo.userType
        let url = "", GetTeacherStu = "api/contact", allData = JSON.parse(JSON.stringify(data));
        let schoolLevel = userInfo.schoolLevel;
        let {
            userId,
            schoolId
        } = userInfo;

        let {
            level, levelId, groupId, nextIsLastLevelFlag, departmentId, path, parentID
        } = data;

        if (!Number(level)) {
            level = 0;
        }

        if (!levelId) {
            levelId = '';
        }
        if (!groupId) {
            groupId = '';
        }

        if (nextIsLastLevelFlag == 1) {
            levelId = parentID
        }

        if (data.contactType) {
            data.value = data.contactType
        } else if (data.departmentId) {
            if (data.departmentList) {
                data.value = 99
            } else {
                data.value = 98
            }
        } else if (data.description) {
            data.value = 14
        } else if (data.groupType) {
            data.value = 88
        } else if (data.teacherCount && userInfo.userType == '1') {
            data.value = 10
        } else if (data.levelId && userInfo.userType == '0') {
            data.value = 6
        } else if (data.studentCount && data.nextIsLastLevelFlag && !levelId) {
            data.value = 8
        } else {
            data.value = 22
        }

        if (data.identityCode) {
            lg_ic = data.identityCode
        }

        switch (String(levelId)) {
            case 'T1':
                if (Number(level) > 2) {
                    groupId = path
                }
                break;
            case 'S1':
                if (Number(level) > 2 && Number(level) < 4) {
                    groupId = path
                }
                break;
            default:
                break;
        }

        if (data.value == 1) {  //最近联系人
            url = GetTeacherStu +
                "/recent?schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId +
                "&identityCode=" + lg_ic +
                "&userType=" + userType +
                "&userId=" + userId;

        }

        if (data.value == 2) {  //常用联系人
            url = GetTeacherStu +
                "/top?schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId +
                "&identityCode=" + lg_ic +
                "&userType=" + userType +
                "&userId=" + userId;

        }

        if (data.value == 5) {
            url = GetTeacherStu +
                "/myclass?userType=" + userType +
                "&userId=" + userId +
                "&schoolId=" + schoolId +
                "&contactType=" + data.contactType +
                "&schoolLevel=" + schoolLevel +
                "&groupId=" + groupId

        }
        console.log(data, 'dasdsa');

        if (data.value == 6) {  //全校师生
            console.log(path, 'path1');

            let id = ''
            if (nextIsLastLevelFlag == '1') {
                id = (groupId ? groupId : schoolId)
            } else {
                if (path) {
                    id = path;
                } else {
                    id = schoolId;
                }
            }
            url = GetTeacherStu +
                "/all?schoolLevel=" + schoolLevel +
                "&level=" + level +
                "&levelId=" + levelId +
                "&groupId=" + id;

        }

        if (data.value == 8) {  //家长
            url = GetTeacherStu +
                // "/parent/else?contactType=" + data.contactType +
                "/parent?contactType=" + (data.contactType || data.value) +
                "&schoolLevel=" + schoolLevel +
                "&userId=" + userId +
                "&groupId=" + (data.path && data.nextIsLastLevelFlag == '0' ? data.path : data.path && data.nextIsLastLevelFlag == '1' ? data.groupId : schoolId) +
                "&schoolId=" + schoolId +
                "&level=" + level
        }

        if (data.value == 22) {  //班级
            // let id = (groupId ? groupId : schoolId)
            let id = ''
            if (nextIsLastLevelFlag == '1') {
                id = (groupId ? groupId : schoolId)
            } else {
                id = data.path;
            }
            url = GetTeacherStu +
                "/all?schoolLevel=" + schoolLevel +
                "&level=" + level +
                "&nextIsLastLevelFlag=" + nextIsLastLevelFlag +
                "&levelId=" + levelId +
                "&groupId=" + id
        }

        if (data.value == 88) {  //我的班级
            url = GetTeacherStu +
                "/user/myclass/list?groupType=" + data.groupType +
                "&contactType=5" +
                "&groupId=" + groupId +
                "&subjectId=" + data.subjectId

        }

        if (data.value == 10) {  //教研组的人
            url = GetTeacherStu +
                "/user/mygroup/list?" +
                "groupId=" + groupId +
                "&schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId
        }

        if (data.value == 12) {  //管理员
            url = GetTeacherStu +
                "/manager?schoolLevel=" +
                "&schoolId=" + schoolId;
        }

        if (data.value == 13) {  //我的讨论组
            url = GetTeacherStu +
                "/group?schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId +
                "&userId=" + userId +
                "&identityCode=" + lg_ic
        }


        if (data.value == 14) {  //管理员
            url = GetTeacherStu +
                "/user/manager/list?schoolLevel=" +
                "&schoolId=" + schoolId +
                "&identityCode=" + lg_ic +
                "&token=" + getNowToken()
        }
        if (data.value == 98) {
            url = GetTeacherStu +
                "/user/organize/list?" +
                "schoolId=" + schoolId + '&departmentId=' + departmentId
        }
        let finalData = await new Promise(function (resolve, reject) {
            HttpGet({
                url: webAddr + url,
            }).then((data) => {
                if (data.code == 200 && Array.isArray(data.data)) {
                    data.data.forEach((item) => {
                        item.name = item.contactName || item.groupName || item.className || `${item.userName}(${item.userId})`;
                        if (!item.nextIsLastLevelFlag && !item.userName) {
                            item.disabled = true;
                        }
                        item.parentID = allData.levelId || allData.groupId;
                    })
                    resolve(data.data);
                } else if (Array.isArray(data.data.studentList)) {
                    data.data.studentList.forEach((item) => {
                        item.name = item.contactName || item.groupName || item.className || `${item.userName}(${item.userId})`;
                        if (!item.nextIsLastLevelFlag && !item.userName) {
                            item.disabled = true;
                        }
                        item.parentID = allData.levelId || allData.groupId;
                    })
                    resolve(data.data.studentList)
                }
            })
        })
        return finalData;
    }
    //选择对象
    const getUserList = (dataList) => {
        let arr = getHasChob([], dataList);
        // console.log(arr);
        // return;
        let userList = [];
        let interval, i = 0;
        arr.forEach(async (item) => {
            if (item.groupId || item.ClassID) {
                let finalData = getGroupData(item);
                finalData.then((res) => {
                    userList = userList.concat(res);
                    i++;
                })

            } else {
                userList.push(item);
                i++;
            }
        })
        interval = setInterval(() => {
            if (i !== arr.length) {
                return;
            }
            let orignList = selectUserList1
            let orignListInfo = {}, allArr = JSON.parse(JSON.stringify(orignList));
            orignList.forEach((item) => {
                orignListInfo[item.userId] = item;
            })
            userList.forEach((item) => {
                if (!orignListInfo[item.userId]) {
                    allArr.push(item);
                }
            })
            // if (allArr.length > 100) {
            //     Taro.showToast({
            //         icon: "none",
            //         title: "最多只能选择100名抄送人",
            //         duration: 2000
            //     })
            //     return;
            // }
            dispatch({ type: 'SET_SELECTUSERLIST', data: setSelectUserList(allArr) });
            let id = Taro.getCurrentInstance().router?.params.id;
            clearInterval(interval);
            Taro.redirectTo({
                url: "/pages/applyStatus/index?id=" + id + "&type=noDeal"
            })
        }, 500);
    }
    //获取用户选择列表
    const getDataInfo = (addr) => {
        // console.log(userInfo, 'userInfo');

        HttpGet({
            url: (addr || webAddr) + "/api/contact",
            data: {
                schoolId: userInfo.schoolId,
                identityCode: userInfo.identityCode,
                userType: userInfo.userType,
                schoolLevel: userInfo.schoolLevel
            },
        }).then((data) => {
            if (data.code == 200 && Array.isArray(data.data)) {
                let arr = [] as any;
                data.data.forEach((item) => {
                    item.name = item.contactName;
                    item.disabled = true;
                    if (item.contactType == 12) {
                        item.name = '校管理员'
                    }
                    //分组
                    // if (item.contactType == 6 || item.contactType == 12 || item.contactType == 11) {
                    if (item.contactType !== '13') {
                        arr.push(item);
                    }
                })

                setReflash(true);
                setSelectDataList(arr);
            }
        })
    }
    //重新获取子目录
    const getChild = (data) => {

        let historyList1 = JSON.parse(JSON.stringify(historyList));
        if (data.parentID) {
            data.levelId = data.parentID
        }

        if (historyList1.some(item => item.name == data.name)) {
            return
        }

        historyList1.push(data);
        setHistoryList(historyList1);
        resetData(data);
    }
    const resetData = (data) => {
        if (data.userId) {
            return;
        }

        // let lg_ic = 'IC0010'
        let lg_ic = userInfo.identityCode
        // let userType = 0
        let userType = userInfo.userType
        let url = "", GetTeacherStu = "api/contact", allData = JSON.parse(JSON.stringify(data));
        let {
            userId,
            schoolId,
            schoolLevel
        } = userInfo;
        let {
            level, levelId, groupId, nextIsLastLevelFlag, departmentId, path, parentID
        } = data;


        if (!Number(level)) {
            level = 0;
        }


        if (!levelId) {
            levelId = '';
        }
        if (!groupId) {
            groupId = '';
        }
        // if (!nextIsLastLevelFlag) {
        //     nextIsLastLevelFlag = 0;
        // }

        if (nextIsLastLevelFlag == 1) {
            levelId = parentID
        }


        if (data.contactType) {
            data.value = data.contactType
        } else if (data.departmentId) {
            if (Array.isArray(data.departmentList)) {
                data.value = 98
            } else {
                data.value = 99
            }
        } else if (data.description) {
            data.value = 14
        } else if (data.groupType) {
            data.value = 88
        } else if (data.teacherCount && userInfo.userType == '1') {
            data.value = 10
        } else if ((data.levelId) && userInfo.userType == '0') {
            data.value = 6
        } else if (data.studentCount && data.nextIsLastLevelFlag && !levelId) {
            data.value = 8
        } else {
            data.value = 22
        }

        if (data.identityCode) {
            lg_ic = data.identityCode
        }

        switch (String(levelId)) {
            case 'T1':
                if (Number(level) > 2) {
                    groupId = path
                }
                break;
            case 'S1':
                if (Number(level) > 2 && Number(level) < 4) {
                    groupId = path
                }
                break;
            default:
                break;
        }

        if (data.value == 1) { //最近联系人
            url = GetTeacherStu +
                "/recent?schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId +
                "&identityCode=" + lg_ic +
                "&userType=" + userType +
                "&userId=" + userId;
        }


        if (data.value == 2) { //常用联系人
            url = GetTeacherStu +
                "/top?schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId +
                "&identityCode=" + lg_ic +
                "&userType=" + userType +
                "&userId=" + userId;

        }

        if (data.value == 5) {
            url = GetTeacherStu +
                "/myclass?userType=" + userType +
                "&userId=" + userId +
                "&schoolId=" + schoolId +
                "&contactType=" + data.contactType +
                "&schoolLevel=" + schoolLevel +
                "&groupId="

        }
        console.log(data, 'dasdaaasa');

        if (data.value == 6) {  //全校师生
            console.log(path, 'path12');

            let id = ''
            if (nextIsLastLevelFlag == '1') {
                id = (groupId ? groupId : schoolId)
            } else {
                if (path) {
                    id = path;
                } else {
                    id = schoolId;
                }
            }
            url = GetTeacherStu +
                "/all?schoolLevel=" + schoolLevel +
                "&level=" + level +
                "&levelId=" + levelId +
                "&groupId=" + id;

        }

        if (data.value == 8) {  //家长
            url = GetTeacherStu +
                // "/parent/else?contactType=" + data.contactType +
                "/parent?contactType=" + (data.contactType || data.value) +
                "&schoolLevel=" + schoolLevel +
                "&userId=" + userId +
                "&groupId=" + (data.path && data.nextIsLastLevelFlag == '0' ? data.path : data.path && data.nextIsLastLevelFlag == '1' ? data.groupId : schoolId) +
                "&schoolId=" + schoolId +
                "&level=" + level
        }

        if (data.value == 22) {  //班级
            let id = ''
            if (nextIsLastLevelFlag == '1') {
                id = (groupId ? groupId : schoolId)
            } else {
                id = data.path;
            }
            url = GetTeacherStu +
                "/all?schoolLevel=" + schoolLevel +
                "&level=" + level +
                "&nextIsLastLevelFlag=" + nextIsLastLevelFlag +
                "&levelId=" + levelId +
                "&groupId=" + id

        }

        if (data.value == 88) {  //我的班级
            url = GetTeacherStu +
                "/user/myclass/list?groupType=" + data.groupType +
                "&contactType=5" +
                "&groupId=" + groupId +
                "&subjectId=" + data.subjectId
        }


        if (data.value == 9) {  //教研组
            url = GetTeacherStu +
                "/mygroup?userId=" + userId +
                "&groupId=" + groupId +
                "&schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId
        }

        if (data.value == 10) {  //教研组的人
            url = GetTeacherStu +
                "/user/mygroup/list?" +
                "groupId=" + groupId +
                "&schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId
        }

        if (data.value == 11) {
            url = GetTeacherStu +
                "/organize/tree?" +
                "schoolId=" + schoolId
        }


        if (data.value == 12) {  //管理员
            url = GetTeacherStu +
                "/manager?schoolLevel=" +
                "&schoolId=" + schoolId;
        }

        if (data.value == 13) {  //我的讨论组
            url = GetTeacherStu +
                "/group?schoolLevel=" + schoolLevel +
                "&schoolId=" + schoolId +
                "&userId=" + userId +
                "&identityCode=" + lg_ic
        }


        if (data.value == 14) {  //管理员
            url = GetTeacherStu +
                "/user/manager/list?schoolLevel=" +
                "&schoolId=" + schoolId +
                "&identityCode=" + lg_ic +
                "&token=" + getNowToken()
        }


        if (data.value == 99) {
            url = GetTeacherStu +
                "/organize?" +
                "schoolId=" + schoolId + '&departmentId=' + departmentId
        }

        if (data.value == 98) {
            url = GetTeacherStu +
                "/user/organize/list?" +
                "schoolId=" + schoolId + '&departmentId=' + departmentId
        }
        HttpGet({
            url: webAddr + url,
            load: true
        }).then((data) => {
            if (data.code == 200 && Array.isArray(data.data)) {
                let selectUserInfo = {};
                selectUserList && selectUserList.forEach((item) => {
                    selectUserInfo[item.userId] = item.userName;
                })

                let i = 0, interval;

                data.data.forEach((item) => {

                    item.name = item.concatGroupName || item.identityName || item.groupName || item.departmentName || item.className || `${item.userName}(${item.userId})`;
                    if (!Number(item.nextIsLastLevelFlag) && !item.userName && !item.groupType) {
                        item.disabled = true;
                    }
                    item.parentID = allData.levelId || allData.classId;
                    if (Number(item.nextIsLastLevelFlag) || item.groupType) {
                        let id = item.groupId || item.classId || item.levelId || userId;
                        let count = 0;
                        selectUserList && selectUserList.forEach((child) => {
                            if (child.parentID == id) {
                                count++;
                            }
                        })
                        let groupRes = getGroupData(item);

                        groupRes.then((groupList) => {
                            // console.log('groupList', groupList, count)
                            if (count > 0 && count < groupList.length) {
                                item.hasCho = 2;
                            }
                            if (count === groupList.length && count != 0) {
                                item.hasCho = 1;
                            }

                            i++;
                        })
                    } else if (item.userId) {
                        item.hasCho = selectUserInfo[item.userId] ? 1 : 0;
                        i++;
                    } else {
                        i++;
                    }

                })
                interval = setInterval(() => {
                    if (i !== data.data.length) {
                        return;
                    }
                    clearInterval(interval);
                    let info = data.data
                    if (Array.isArray(allData.departmentList) && allData.departmentList.length > 0) {
                        allData.departmentList.forEach((item) => {
                            item.name = item.departmentName
                            item.disabled = true
                        })
                        info = [...allData.departmentList, ...info]
                    }

                    setSelectDataList(info);
                }, 200);
            } else if (data.data?.studentList) {
                let selectUserInfo = {};
                selectUserList && selectUserList.forEach((item) => {
                    selectUserInfo[item.userId] = item.userName;
                })
                let i = 0, interval;

                data.data.studentList.forEach((item) => {
                    item.name = item.concatGroupName || item.identityName || item.groupName || item.departmentId || item.className || `${item.userName}(${item.userId})`;
                    if (!Number(item.nextIsLastLevelFlag) && !item.userName && !item.groupType) {
                        item.disabled = true;
                    }
                    item.parentID = allData.levelId || allData.classId;

                    if (Number(item.nextIsLastLevelFlag) || item.groupType) {
                        let id = item.groupId || item.classId || item.levelId;
                        let count = 0;
                        selectUserList && selectUserList.forEach((child) => {
                            if (child.parentID === id) {
                                count++;
                            }
                        })
                        let groupRes = getGroupData(item);

                        groupRes.then((groupList) => {
                            // console.log('groupList', groupList)
                            if (count > 0 && count < groupList.length) {
                                item.hasCho = 2;
                            }
                            if (count === groupList.length) {
                                item.hasCho = 1;
                            }

                            i++;
                        })
                    } else if (item.userId) {
                        // console.log('hasCho')
                        item.hasCho = selectUserInfo[item.userId] ? 1 : 0;
                        i++;
                    } else {
                        i++;
                    }

                })

                interval = setInterval(() => {
                    // console.log(data.data, 'data.data')
                    if (i !== data.data.studentList.length) {
                        return;
                    }
                    clearInterval(interval);

                    setSelectDataList(data.data.studentList);
                }, 200);
            } else if (data.data?.peopleList) {
                let selectUserInfo = {};
                selectUserList && selectUserList.forEach((item) => {
                    selectUserInfo[item.userId] = item.userName;
                })
                let i = 0, interval;

                data.data.peopleList.forEach((item) => {
                    item.name = item.concatGroupName || item.identityName || item.departmentId || item.className || `${item.userName}(${item.userId})`;
                    if (!Number(item.nextIsLastLevelFlag) && !item.userName && !item.groupType) {
                        item.disabled = true;
                    }
                    item.parentID = allData.levelId || allData.classId;

                    if (Number(item.nextIsLastLevelFlag) || item.groupType) {
                        let id = item.groupId || item.classId || item.levelId;
                        let count = 0;
                        selectUserList && selectUserList.forEach((child) => {
                            if (child.parentID === id) {
                                count++;
                            }
                        })
                        let groupRes = getGroupData(item);

                        groupRes.then((groupList) => {
                            // console.log('groupList', groupList)
                            if (count > 0 && count < groupList.length) {
                                item.hasCho = 2;
                            }
                            if (count === groupList.length) {
                                item.hasCho = 1;
                            }

                            i++;
                        })
                    } else if (item.userId) {
                        // console.log('hasCho')
                        item.hasCho = selectUserInfo[item.userId] ? 1 : 0;
                        i++;
                    } else {
                        i++;
                    }

                })

                interval = setInterval(() => {
                    // console.log(data.data, 'data.data')
                    if (i !== data.data.peopleList.length) {
                        return;
                    }
                    clearInterval(interval);

                    setSelectDataList(data.data.peopleList);
                }, 200);
            } else {
                setSelectDataList([])
            }
        })
    }
    const historyClick = (data) => {
        if (data.name === "全部") {
            getDataInfo(webAddr);
            setHistoryList([{ name: "全部" }]);
            return;
        }
        resetData(data);

        let historyList1 = JSON.parse(JSON.stringify(historyList));
        let targetIndex = "";
        historyList1.forEach((item, index) => {
            if (item.name === data.name) {
                targetIndex = index;
            }
        })
        let arr = historyList1.slice(0, targetIndex + 1);
        setHistoryList(arr);
    }
    const confirm = () => {
        let params = Taro.getCurrentInstance().router?.params

        let dealSelectArr = JSON.parse(JSON.stringify(selectUserList))
        if (selectUserList.length > 0) {
            dealSelectArr.forEach((item) => {
                item.photoPath = item.photoPath || item.avatarPath
            })
        }
        // dispatch(setSelectUser(dealSelectArr))
        dispatch({ type: 'SET_SELECTUSERLIST', data: setSelectUser(dealSelectArr) });
        Taro.navigateBack({})
    }
    //处理添加删除选择用户操作
    const handleItem = (data, targetIndex) => {
        let showList = JSON.parse(JSON.stringify(selectDataList));
        let list = JSON.parse(JSON.stringify(selectUserList));
        if (!showList[targetIndex].hasCho) { //添加
            showList[targetIndex].hasCho = 1;
            if (!data.userId) {
                let finalData = getGroupData(data);
                finalData.then((res) => {
                    // console.log(res)
                    list = list.concat(res);
                    setSelectUserList(list);
                    setSelectDataList(showList);
                })
            } else {
                list.push(data);
                setSelectUserList(list);
                setSelectDataList(showList);
            }
        } else {   //删除
            showList[targetIndex].hasCho = 0;
            if (data.groupId || data.ClassID) {
                let id = data.groupId || data.ClassID;
                let arr = list.filter((item) => {
                    return item.parentID !== id;
                })
                setSelectUserList(arr);
                setSelectDataList(showList);
            } else {
                let i = -1;
                list.forEach((item, index) => {
                    if (item.userId === data.userId) {
                        i = index;
                    }
                })
                list.splice(i, 1);
                setSelectUserList(list);
                setSelectDataList(showList);
            }
        }

    }
    //获取选择列表
    useEffect(() => {
        document.title = "参与人选择"
        //获取办公平台地址
        setHistoryList([{ name: "全部" }]);
        setSelectUserList(selectUserList1);
        setWebAddr(baseUrl);
        getDataInfo(baseUrl);
        return () => {
            document.title = "详情"
        }
    }, []);
    const goBack = () => {
        Taro.navigateBack({
            delta: 1
        })
    }
    // console.log('%',historyList,'%',selectDataList)
    return (
        <View className={`select_user`}>
            {
                Utils.getQueryVariable('env') === 'weapp' || window.__wxjs_environment === 'miniprogram' ?
                    "" :
                    <Header
                        className='header-top'
                        mainTitle='参与人选择'
                        mainTitleBold={false}
                        isTitlePositionLeft={true}
                        needMainIcon={process.env.TARO_ENV === 'weapp' ? false : true}
                        onClick={Taro.getCurrentInstance().router?.params.from ? goBack : ''}
                    />
            }

            <View className="router_list">
                {
                    historyList.map((item, index) => {
                        return (
                            <View className="router_one" key={index} onClick={index === historyList.length - 1 ? () => { } : () => historyClick(item)}>
                                {item.name}
                                {
                                    index === historyList.length - 1 ?
                                        "" :
                                        <View className="my_icon icon-b01901"></View>
                                }

                            </View>
                        )
                    })
                }
            </View>
            <View className="show_list">
                {
                    selectDataList.length > 0 ?
                        selectDataList.map((item, index) => {
                            // if(item.ContactGroupType == 17){
                            //     return;
                            // }
                            console.log(item, 'itemitemitemitem');

                            return (
                                <View className="list_one" key={index}>

                                    <View className="one_title">
                                        {
                                            item?.level == '1' ? <i className={'icon-list icon-item-' + item?.contactType}></i> : ''}
                                        {
                                            item.disabled ?
                                                "" :
                                                <LgCheckbox
                                                    type='B'
                                                    default={0}
                                                    value={item.hasCho}
                                                    onClick={() => handleItem(item, index)} />
                                        }
                                        {item.name}
                                    </View>
                                    {
                                        item.userId ?
                                            "" :
                                            <View className="my_icon icon-b01901" onClick={() => getChild(item)}></View>
                                    }

                                </View>
                            )
                        }) :
                        <LgEmpty text="暂无可选对象" type='B' />
                }
            </View>
            {/* </View> */}
            {/* <View className="operate_btn">
                <LgButton className="confirm_btn" type='B' width={690} height={88} onClick={confirm}>确定</LgButton>
            </View> */}
            <SingleButtonFooter buttonText={'确定' + (selectUserList.length > 0 ? '(已选中' + selectUserList.length + '个)' : '')} onClick={confirm} type="B" />
        </View>
    )
}

const mainProps = ({ commonData }) => {
    return {
        userInfo: commonData.userInfo,
        leaveAddr: commonData.leaveAddr,
        oaAddr: commonData.oaAddr,
        lg_ic: commonData.lg_ic,
        env: commonData.env,
        selectUserList1: commonData.selectUserList,
        baseUrl: commonData.baseUrl,
    }
}

export default connect(mainProps)(App)
